<template>
    <div :class="['nav', isShow ? '' : 'dark']">
        <div class="nav-container common">
            <!-- 用来seo ,利于搜索抓取-->
            <div :class="[isShow ? 'white-img' : 'dark-img']">
                <h1>叩丁严选</h1>
            </div>
            <div class="nav-container-head">
                <ul>
                    <li>
                        <router-link to="/index">首页</router-link>
                    </li>
                    <li class="all" @click="init">
                        <router-link to="/goods">全部礼品</router-link>
                    </li>
                    <li>
                        <router-link to="/">个人中心</router-link>
                    </li>
                    <li>
                        <router-link to="/">我的订单</router-link>
                    </li>
                    <li>
                        <router-link to="/">专属福利</router-link>
                    </li>
                </ul>
            </div>
            <div class="thesearch">
                <div class="search">
                    <input type="text" name="" id="text" placeholder="请输入关键字" v-model.trim="val"
                        @keypress.enter="searchHandle">
                </div>
                <div class="btn">
                    <button @click="searchHandle"><i class="bi bi-search"></i></button>

                </div>
            </div>
        </div>

    </div>

</template>

<script>


export default {
    data() {
        return {
            val: '',
        }
    },
    props: {
        isShow: {
            type: Boolean,
            default: false
        }
    }, methods: {
        push_index() {
            this.$router.push('/index')
        },
        init() {
            // js方法实现刷新，使跳转后在顶部，或者在生命周期使用document.documentElement.scrollTop = 0
            let name = '全部礼品'
            location.href = '/goods?name=' + name
        },
        searchHandle() {
            if (this.val.length == 0) {
                alert('搜索内容不能为空！请输入搜索内容！')
                return;
            }
            location.href = '/goods?name=全部礼品&keyword=' + this.val

        }

    }, created() {


        // var all = document.querySelector('.all')
        // console.log(all);

    }
}
</script>

<style lang="less" scoped>
.dark {
    background-color: #242b39;
    border-top: 2px solid rgba(49, 58, 75);

    li {
        &:first-child a {
            color: #fff !important;
        }

        a {
            color: #78859f !important;

            &:hover {
                color: #fff !important;

            }
        }
    }
}

.white-img {
    width: 257px;
    height: 73px;
    background: url("@/assets/img/logo1.png") no-repeat center;
}

.dark-img {
    width: 257px;
    height: 73px;
    background: url("@/assets/img/logo2.png") no-repeat center;

}

.nav {
    padding-top: 12px;
    height: 87px;
    font-size: 16px;
    font-weight: 700;

    .nav-container {
        display: flex;
        justify-content: space-between;

        h1 {
            // 首行缩进
            position: absolute;
            text-indent: -9999px;
        }

        .nav-container-head {
            display: flex;
            align-items: flex-end;
            padding: 0 68px;


            ul {
                display: flex;
                width: 512px;
                justify-content: space-between;
                margin-bottom: 10px;

                a {
                    text-decoration: none;
                    color: #000;

                    &:hover {
                        color: #0a328e;
                    }
                }
            }



        }

        .thesearch {
            display: flex;
            align-items: flex-end;
            margin-bottom: -8px;

            .search {
                width: 214px;
                height: 40px;
                border: 1px solid #DEDEDE;
                overflow: hidden;
                border-radius: 20px 0 0 20px;
                border-right: 0;
                margin-bottom: 5px;
                box-sizing: border-box;
                // border: 0 !important;

                input {
                    width: 100%;
                    border: 0;
                    height: 36px;
                    outline: 0;
                    text-indent: 15px;
                    font-size: 13px;

                    // background-color: #242B39;
                    // color: #fff;
                }
            }

            .btn {
                margin-bottom: 5px;

                button {
                    width: 50px;

                    height: 40px;
                    border-radius: 0 20px 20px 0;
                    background-color: #0a328e;
                    border: 0;
                    vertical-align: middle;
                    text-align: center;

                    i {
                        color: #FFFFFF;
                        cursor: pointer;
                    }
                }
            }
        }
    }


}
</style>